package com.nsxy.manager.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nsxy.common.service.BaseService;
import com.nsxy.common.utils.Criteria;
import com.nsxy.manager.user.beans.Account;
import com.nsxy.manager.user.dao.AccountRepository;

/**
 * @author 潜行的青衣
 * @see
 */
@Service
public class AccountService extends BaseService<Account, String, AccountRepository> implements IAccountService {

	/**
	 * @param repository
	 */
	@Autowired
	public AccountService(AccountRepository repository) {
		super(repository);
	}

	/* (non-Javadoc)
	 * @see com.nsxy.manager.user.service.IAccountService#findByAccount(java.lang.String)
	 */
	@Override
	public Account findByAccount(String account) {
		Criteria<Account> criteria = new Criteria<Account>();
		criteria.and().eq("account", account);
		criteria.and().eq("status", Account.STATUS_VALID);
		return this.repository.findOne(criteria.toSpecifications());
	}

}
